#!/usr/bin/perl
#
$totalRules = 0;
open(FILE,$ARGV[0]);
while($line=<FILE>) {
	($a,$b,$left,$right)=split(/\s+/,$line);
	if($b>$ARGV[1]) {
		$isThere{$left}=1;
		$isThereLR{"$left:::::$right"}=1;
		$totalRules++;
	}
}

$hitsL=0;
$hitsLR=0;
$all=0;
while($line=<STDIN>) {
	chomp($line);
	($left,$right)=split(/\s+/,$line);
	if($isThere{$left}) {
		$hitsL++;
	}
	if($isThereLR{"$left:::::$right"}) {
		$hitsLR++;
	}
	$all++;	
}

print "$totalRules\t";
print $hitsL*100/$all."\t";
print $hitsLR*100/$all."\t";
print $hitsLR*100/$hitsL."\n";
